package com.pkk.penguin.frame.know.java.interview.singleton;

import java.util.concurrent.TimeUnit;

/**
 * @description: 单例模式-懒汉式
 * @author: peikunkun
 * @create: 2019-12-28 17:36
 **/
public class SingletonInterview2 {

  private static SingletonInterview2 singletonInterview2 = null;

  /**
   * @Description: 获取实例
   * @Param: [isDelay:是否延迟]
   * @return: com.pkk.penguin.frame.know.java.interview.singleton.SingletonInterview2
   * @Author: peikunkun
   * @Date: 2019/12/28 下午5:45
   */
  public static SingletonInterview2 getInstance(boolean isDelay) throws InterruptedException {
    if (null == singletonInterview2) {
      if (isDelay) {
        TimeUnit.SECONDS.sleep(1);
      }
      singletonInterview2 = new SingletonInterview2();
    }
    return singletonInterview2;
  }

}
